package com.springStudy;

import com.ioCStudy.component.A;
import com.ioCStudy.component.B;
import com.ioCStudy.config.JavaConfig;
import com.ioCStudy.controller.StudentController;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

// @SpringJUnitConfig(locations = 指定配置文件, value = 指定配置类)
@SpringJUnitConfig(value=JavaConfig.class)
public class IoCTest_01 {

    @Autowired
    private A a;

    @Autowired
    private B b;

    @Test
    public void testFindAll() {

        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(JavaConfig.class);

        StudentController controller = applicationContext.getBean(StudentController.class);

        controller.findAll();
    }

    @Test
    public void testAB() {
        System.out.println(a);
        System.out.println(b);
    }


}
